<template>
	<view>
		<!-- 导航栏组件，可左右放内容 fixed让导航栏固定在上方-->
		<uni-nav-bar :fixed="true" :status-bar="true" title="数据展示"  leftIcon="left" rightText="财务明细"
			@clickLeft="back" @clickRight="tomingxi" />
		<!-- 最上方的图片 -->
		<!-- <view style="display: flex;position: relative;z-index: 1; width: 100%;">
			<image style="width: 100%;" src="../../static/my1.jpg" mode="widthFix"></image>
		</view> -->
		<!-- 图片上的文字 -->
		<!-- <view style="display: flex; position: relative;z-index: 2; margin-top: -300rpx;flex-direction: column;"> -->
		<!-- <view style="display: flex;background-image:url(~@../../static/my1.jpg);background-size: 100% 100%;background-repeat: no-repeat;width: 750rpx;height: 300rpx;overflow: hidden;flex-direction: column;">
			<view  v-if="kehuinfo.partner==1" style="display: flex;font-size: 24rpx;margin: 30rpx 50rpx 0 560rpx;color: red;background-color: white;border-radius: 10rpx;align-content: center;justify-content: center;" @click="yuejiesuan">
				
			</view>
			<view
				style="display: flex; color: white;font-size: 58rpx;font-weight: 700;align-items: flex-end; justify-content: center;margin: 20rpx 0;">
				{{ | formatPrice }}
			</view>
			<view style="display: flex; color: white;font-size: 35rpx;justify-content: center;">
				数据展示
			</view>
		</view> -->
		<!-- 钱包排版 -->
		<view
			style="display: flex;position: relative;z-index: 3;width: 98%;justify-content: center; margin: 15rpx auto 0 auto;">
			<view
				style="display: flex;width: 95%;background-color:white; flex-direction: column;padding: 15rpx 15rpx 38rpx 15rpx;border-radius: 20rpx;">
				<view style="display: flex;flex-direction: row;align-items: center;margin: 5rpx 0 10rpx 0 ;">
					<view
						style="display: flex; width: 10rpx;height: 32rpx; margin: 0 10rpx 0 10rpx;border-radius: 15rpx; background-color: red;">
					</view>
					数据统计
				</view>
				<!-- 第一行两张图片 -->
				<view style="display: flex;width: 100%;justify-content: space-around;flex-direction: row;">
					<view style="display: flex;width: 48%;flex-direction: column;" @click="tixian(1)">
						<view
							style="display: flex;background-image:url(~@../../static/shouyi1.jpg);background-size: 100% 100%;background-repeat: no-repeat;width: 340rpx;height: 170rpx;overflow: hidden; border-radius: 20rpx; justify-content: center;flex-direction: column; color: black;">
							<view style="display: flex;justify-content: center;font-size: 50rpx;">
								{{shuju.res1.total }}
							</view>
							<view
								style="display: flex;justify-content: center;font-size: 30rpx;margin-top: 10rpx;color: white;">
								在读学员数量
							</view>
						</view>
					</view>
					<view style="display: flex;width: 48%;flex-direction: column;" @click="tixian(2)">
						<view
							style="display: flex;background-image:url(~@../../static/shouyi2.jpg);background-size: 100% 100%;background-repeat: no-repeat;width: 340rpx;height: 170rpx;overflow: hidden; border-radius: 20rpx;justify-content: center;flex-direction: column; color: black;">
							<view style="display: flex;justify-content: center;font-size: 50rpx;">
								{{shuju.res2.total}}
							</view>
							<view
								style="display: flex;justify-content: center;font-size: 30rpx;margin-top: 10rpx;color:white;">
								任课老师数量
							</view>
						</view>
					</view>
				</view>
				<!-- 第二行两张图片 -->
				<view
					style="display: flex;width: 100%;justify-content: space-around;flex-direction: row;margin-top: 20rpx;">
					<view style="display: flex;width: 48%;flex-direction: column;" @click="tixian(3)">
						<view
							style="display: flex;background-image:url(~@../../static/shouyi3.jpg);background-size: 100% 100%;background-repeat: no-repeat;width: 340rpx;height: 170rpx;overflow: hidden; border-radius: 20rpx;justify-content: center;flex-direction: column; color: black;">
							<view style="display: flex;justify-content: center;font-size: 50rpx;">
								{{shuju.res3.data[0].shengyukeshi}}
							</view>
							<view
								style="display: flex;justify-content: center;font-size: 30rpx;margin-top: 10rpx;color: white;">
								剩余课时
							</view>
						</view>
					</view>
					<view style="display: flex;width: 48%;flex-direction: column;" @click="tixian(4)">
						<view
							style="display: flex;background-image:url(~@../../static/shouyi4.jpg);background-size: 100% 100%;background-repeat: no-repeat;width: 340rpx;height: 170rpx;overflow: hidden; border-radius: 20rpx;justify-content: center;flex-direction: column; color: black;">
							<view style="display: flex;justify-content: center;font-size: 50rpx;">
								{{shuju.res3.data[0].shengyuxuefei| formatPrice }}
							</view>
							<view
								style="display: flex;justify-content: center;font-size: 30rpx;margin-top: 10rpx;color: white;">
								剩余课时学费
							</view>
						</view>
					</view>
				</view>
				<!-- 第三行两张图片 -->
				<view style="display: flex;width: 100%;justify-content: space-around;flex-direction: row;margin-top: 20rpx;">
					<view style="display: flex;width: 48%;flex-direction: column;" @click="tixian(6)">
						<view
							style="display: flex;background-image:url(~@../../static/shouyi1.jpg);background-size: 100% 100%;background-repeat: no-repeat;width: 340rpx;height: 170rpx;overflow: hidden; border-radius: 20rpx; justify-content: center;flex-direction: column; color: black;">
							<view style="display: flex;justify-content: center;font-size: 50rpx;">
								{{benyueshouru }}
							</view>
							<view
								style="display: flex;justify-content: center;font-size: 30rpx;margin-top: 10rpx;color: white;">
								本月收入
							</view>
						</view>
					</view>
					<view style="display: flex;width: 48%;">
						<view  style="display: flex;width: 100%;flex-direction: column;" @click="tixian(7)">
							<view
								style="display: flex;background-image:url(~@../../static/shouyi2.jpg);background-size: 100% 100%;background-repeat: no-repeat;width: 340rpx;height: 170rpx;overflow: hidden; border-radius: 20rpx;justify-content: center;flex-direction: column; color: black;">
								<view style="display: flex;justify-content: center;font-size: 50rpx;">
									{{benyuezhichu}}
								</view>
								<view
									style="display: flex;justify-content: center;font-size: 30rpx;margin-top: 10rpx;color:white;">
									本月支出
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>

	export default {
		data() {
			return {
				benyueshouru:0,
				benyuezhichu:0,
				kehuinfo:[],
				shuju:[],
				isshuju:0
			};
		},
		onLoad() {
			this.shujufun()
		},
		// 下面是定义数值两位小数，且不是四舍五入
		filters: {
			formatPrice(data) {
				if (typeof(data) === "number") {
					return parseFloat(data).toFixed(3).substring(0, parseFloat(data).toFixed(3).length - 1)
				}
				return ;
			}
		},
		methods: {
			shujufun(){
				uni.showLoading({
					title:"数据加载中……",
					mask:true,
					 
				})
				uniCloud.callFunction({
					name:"shujuTongji",
					data:{
						leixing:1,//类型为20时，把财务明细添加到数据库中
					}
				}).then(res=>{
					uni.hideLoading()
					console.log('11',res)
					this.shuju=res.result
					if(this.shuju.res4.data.length){
						if(this.shuju.res4.data[0].biandong=='收入'){
							this.benyueshouru=this.shuju.res4.data[0].jine
							this.benyuezhichu=this.shuju.res4.data[1].jine
						}else{
							this.benyueshouru=this.shuju.res4.data[1].jine
							this.benyuezhichu=this.shuju.res4.data[0].jine
						}
					}
					
				})
			},
			//月结算跳转
			yuejiesuan(){
				uni.navigateTo({
					url: '/pages/yuejiesuan/yuejiesuan'
				})
			},
			// 提现
			tixian(e) {
				uni.navigateTo({
					url: '/pages/caskback/caskback?id=' + e
				})
			},
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			tomingxi() {
				uni.navigateTo({
					url: '/pages/caiwu/caiwu'
				})
			},
			showtip(index) {
				if (index == 1) {
					this.openparam('tip1');
				}
				if (index == 2) {
					this.openparam('tip2');
				}
				if (index == 3) {
					this.openparam('tip3');
				}
				if (index == 4) {
					this.openparam('tip4');
				}
			},
			/**
			 * @description  查看明细
			 */
			toDetail(type) {
				console.log(type);
				uni.navigateTo({
					url: '/pages/earnings/detail?type=' + type
				});
			},
			/**
			 * @description 提现操作
			 * @param {Object} type 提现类型
			 */
			caskBack(type) {
				uni.navigateTo({
					url: '../caskback/caskback?type=' + type
				});
			},
			toTopup() {
				uni.navigateTo({
					url: '../topup/topup'
				});
			}
		}
	};
</script>

<style lang="scss">
	page {
		background: #f5f5f5;
	}

	.infobox1 {
		background: linear-gradient(to right, #12c8f9, #00a6ff);
		margin: 30rpx;
		border-radius: 20rpx;
		padding: 20rpx;

		>.title {
			display: flex;
			align-items: center;
			justify-content: space-between;
			color: #fff;

			>view:nth-child(1) {
				font-weight: bold;
				font-size: 28rpx;
			}

			>view:nth-child(2) {
				font-size: 24rpx;
			}
		}

		>.price {
			font-size: 50rpx;
			color: #fff;
		}

		>.btnbox {
			display: flex;
			align-items: center;
			margin-top: 50rpx;

			>view {
				background: #fff;
				color: #00a6ff;
				font-size: 24rpx;
				border-radius: 50rpx;
				width: 200rpx;
				text-align: center;
				padding: 14rpx 0;
				margin: 0 50rpx 0 0;
			}

			>navigator {
				background: #fff;
				color: #00a6ff;
				font-size: 24rpx;
				border-radius: 50rpx;
				width: 200rpx;
				text-align: center;
				padding: 14rpx 0;
				margin: 0 50rpx 0 0;
			}
		}
	}

	.titlebox {
		color: #333;
		font-size: 28rpx;
		margin: 0 30rpx;
	}

	.infobox2 {
		margin: 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		flex-wrap: wrap;

		>.block {
			width: 48%;
			padding: 20rpx;
			border-radius: 10rpx;
			color: #333;
			margin: 0 0 20rpx 0;

			>.title {
				// font-weight: bold;
				font-size: 30rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				>.icon {
					width: 40rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}
			}

			>.price {
				margin-top: 30rpx;
			}
		}

		>.block:nth-child(1) {
			background: #fcfaeb;
		}

		>.block:nth-child(2) {
			background: #eefcff;
		}

		>.block:nth-child(3) {
			background: #12c8f9;
		}
	}
</style>
